<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数据渲染前预处理</title>
</head>

<body>


  <h1>数据渲染前预处理</h1>
  <!--载入vue.js-->
  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>

  <div id="Application">
    <ul>
      <li v-for="( item, index ) in handle( list )" :key="index">
        <div>{{ index + "." + item.name }}</div>
        <div>{{ item.num }}</div>
      </li>
    </ul>
  </div>

  <script>
    const App = {
      data() {
        return {
          list: [
            {
              name: "辉少",
              num: "asdfsadf",
            },
            {
              name: "Jack",
              num: "5234234",
            },
            {
              name: "Tim",
              num: "41234",
            },
            {
              name: "Lucy",
              num: "241234",
            },
            {
              name: "Baobo",
              num: "234234",
            },
          ],
        };
      },

      methods: {
        handle(l) {
          return l.filter((obj) => obj.name != "辉少");
          //filter：它创建一个新数组，新数组中的元素是通过检查指定数组中符合条件的所有元素。
        },
      },
    };

    Vue.createApp(App).mount("#Application");
  </script>
</body>

</html>